home *** CD-ROM | disk | FTP | other *** search
/ cyber.net interactivo 1997 March / inter@ivo 1997-03.iso / wing / cmacro32.in_ / cmacro32.in
Text File  |  1994-08-13  |  21KB  |  1,484 lines

  1. ?386regs=1
  2. PMODE=1
  3. ?WIN=0
  4. ?SMALL=1
  5.  
  6. ifndef ?auto32
  7.     ?auto32 = 1
  8. endif
  9.  
  10. comment $
  11. cmacros - assembly macros for interfacing to hlls
  12. (C) Copyright 1984-1994 Microsoft Corp.  All rights reserved.
  13. $
  14. .xcref
  15. .xcref ??_out
  16. ??_out macro t
  17. ifndef ?QUIET
  18. %out t
  19. endif
  20. endm
  21. outif macro name,defval,onmsg,offmsg
  22. ifndef name
  23. ifb <defval>
  24. name=0
  25. else
  26. name=defval
  27. endif
  28. endif
  29. if name
  30. name=1
  31. ifnb <onmsg>
  32. ??_out <! onmsg>
  33. endif
  34. else
  35. ifnb <offmsg>
  36. ??_out <! offmsg>
  37. endif
  38. endif
  39. endm
  40. .xcref ??error
  41. ??error macro msg
  42. e r r o r ----- msg
  43. .err
  44. endm
  45. .xcref ASMpass
  46. .xcref memS,memM,memL,memC,memH,memMOD,sizec,sized
  47. if1
  48. ASMpass=1
  49. ifdef ?SMALL
  50. memS=1
  51. endif
  52. ifdef ?MEDIUM
  53. memM=1
  54. endif
  55. ifdef ?COMPACT
  56. memC=1
  57. endif
  58. ifdef ?LARGE
  59. memL=1
  60. endif
  61. ifdef ?HUGE
  62. memH=1
  63. endif
  64. ??_out <cMacros WinG 32-bit Version - Copyright (C) 1994 Microsoft Corp.>
  65. outif memS,0,<Small model>
  66. outif memM,0,<Medium model>
  67. outif memL,0,<Large model>
  68. outif memC,0,<Compact model>
  69. outif memH,0,<Huge model>
  70. outif ?auto32,0,<Discardable 32bit code segment hack enabled>
  71. memMOD= memS + memM + memL + memC + memH
  72. if memMOD ne 1
  73. if memMOD eq 0
  74. memS = 1
  75. else
  76. ??error <more than 1 memory model selected>
  77. endif
  78. endif
  79. sizec= memM + memL + memH
  80. sized= memL + memC + (memH*2)
  81. outif ?DF,0,<No segments or groups will be defined>
  82. outif ?TF,0,<Epilog sequences assume valid SP>
  83. outif ?WIN,1,<Windows support>
  84. ifdef PMODE
  85. ?pmd=1
  86. ??_out <! 386 protect mode use32>
  87. else
  88. ?pmd=0
  89. endif
  90. ifdef ?386regs
  91. if ?386regs
  92. ??_out <! 386 registers enabled>
  93. endif
  94. else
  95. ?386regs=0
  96. endif
  97. if ?WIN eq 1
  98. outif ?PLM,1,<>
  99. else
  100. outif ?PLM,1,<Pascal calling convention>
  101. endif
  102. ifndef ?NODATA
  103. ?nodata1=0
  104. else
  105. ?nodata1=1
  106. ??_out <! NODATA module>
  107. endif
  108. ifndef ?CHKSTK
  109. ?chkstk1=0
  110. else
  111. ?chkstk1=1
  112. ifdef ?CHKSTKPROC
  113. ??_out <! Private stack checking enabled>
  114. else
  115. ??_out <! Stack checking enabled>
  116. endif
  117. endif
  118. ifndef DOS5
  119. ?DOS5=0
  120. else
  121. ?DOS5=1
  122. ??_out <! DOS5 module>
  123. endif
  124. ifdef ?PROFILE
  125. ??_out <! Native profiling enabled>
  126. endif
  127. else
  128. ASMpass=2
  129. endif
  130. ifdef ?pmd
  131. ;.286p
  132. .386p
  133. endif
  134. if ?386regs
  135. .xcref ?n,?ax,?eax,?bx,?ebx
  136. .xcref ?cx,?ecx,?dx,?edx
  137. .xcref ?si,?esi,?di,?edi,?es,?ds,?fs
  138. .xcref ?gs
  139. else
  140. .xcref ?n,?ax,?ah,?al,?bx,?bh
  141. .xcref ?bl,?cx,?ch,?cl,?dx,?dh
  142. .xcref ?dl,?si,?di,?es,?ds,?bp
  143. .xcref ?sp,?ss,?cs
  144. endif
  145. .xcref ?rsl,?cpd,?argl,?argc,?ba
  146. .xcref ?acb,???,?po
  147. .xcref ?pas,?pc
  148. .xcref uconcat,mpush,mpop
  149. .xcref ?ri,?pp,?pp1,?al1
  150. .xcref ?ad,?ap,?atal,?dd,?dd1,?dd2
  151. .xcref ?pg,?pg1,?aloc,?cs1,?cs2
  152. .xcref ?DF,?TF,?ff,?PLM,?WIN,?ia,?pu,?adj
  153. .xcref ?uf,?rp,?nx,?nd,?nodata1,?chkstk1,?DOS5,?pmd,?lds,?exp
  154. .xcref ?wfp,arg,cCall,cProc,assumes,?cs3,?cs2,?cs1
  155. .xcref defgrp,addseg,createSeg
  156. .xcref save,outif,errnz,errn$,errnz1
  157. .xcref ?PLMPrevParm,?gcc
  158. .xcref ?cCall1,?pcc
  159. ?rsl = 0
  160. ?cpd = 0
  161. ?argl = 0
  162. ?argc = 0
  163. ?ba = 0
  164. ?acb = 0
  165. ??? = 0
  166. ?po = 0
  167. ?pas = 0
  168. ?pc = 0
  169. ?ia = 0
  170. ?pu = 0
  171. ?adj = 0
  172. ?rp = 0
  173. ?uf = 0
  174. ?nd = 0
  175. ?nx = 0
  176. ?wfp = 0
  177. ?lds = 0
  178. ?exp = 0
  179. ?ff = 0
  180. ?dd2 = 0
  181. ?cCall1 = 0
  182. ?pcc = 0
  183. ?PLMPrevParm = 0
  184. .xcref ?casen
  185. if1
  186. ?casen = 0
  187. endif
  188. if ?386regs
  189. ?n = 0000000000000000b
  190. ?ax = 0000000000000001b
  191. ?eax = 0000000000000010b
  192. ?bx = 0000000000000100b
  193. ?ebx = 0000000000001000b
  194. ?cx = 0000000000010000b
  195. ?ecx = 0000000000100000b
  196. ?dx = 0000000001000000b
  197. ?edx = 0000000010000000b
  198. ?si = 0000000100000000b
  199. ?esi = 0000001000000000b
  200. ?di = 0000010000000000b
  201. ?edi = 0000100000000000b
  202. ?ds = 0001000000000000b
  203. ?es = 0010000000000000b
  204. ?fs = 0100000000000000b
  205. ?gs = 1000000000000000b
  206. else
  207. ?n = 0000000000000000b
  208. ?ax = 0000000000000011b
  209. ?ah = 0000000000000001b
  210. ?al = 0000000000000010b
  211. ?bx = 0000000000001100b
  212. ?bh = 0000000000000100b
  213. ?bl = 0000000000001000b
  214. ?cx = 0000000000110000b
  215. ?ch = 0000000000010000b
  216. ?cl = 0000000000100000b
  217. ?dx = 0000000011000000b
  218. ?dh = 0000000001000000b
  219. ?dl = 0000000010000000b
  220. ?si = 0000000100000000b
  221. ?di = 0000001000000000b
  222. ?es = 0000010000000000b
  223. ?ds = 0000100000000000b
  224. ?bp = 0001000000000000b
  225. ?sp = 0010000000000000b
  226. ?ss = 0100000000000000b
  227. ?cs = 1000000000000000b
  228. endif
  229. .cref
  230. uconcat macro a,b,c,d,e,f,g
  231. a&b c&d e&f&g
  232. endm
  233. if ?386regs
  234. mpush macro r
  235. irp x,<ax,eax,bx,ebx,cx,ecx,dx,edx,si,esi,di,edi,ds,es,fs,gs>
  236. if (r and ?&&x)
  237.     push    x
  238. endif
  239. endm
  240. endm
  241. else
  242. mpush macro r
  243. irp x,<ax,bx,cx,dx,si,di,es,ds,bp,sp,ss,cs>
  244. if (r and ?&&x)
  245.     push    x
  246. endif
  247. endm
  248. endm
  249. endif
  250. if ?386regs
  251. mpop macro r
  252. irp x,<gs,fs,es,ds,edi,di,esi,si,edx,dx,ecx,cx,ebx,bx,eax,ax>
  253. if (r and ?&&x)
  254.     pop    x
  255. endif
  256. endm
  257. endm
  258. else
  259. mpop macro r
  260. irp x,<cs,ss,sp,bp,ds,es,di,si,dx,cx,bx,ax>
  261. if (r and ?&&x)
  262.     pop    x
  263. endif
  264. endm
  265. endm
  266. endif
  267. save macro r
  268. ?rsl=0
  269. ?ri ?rsl,<r>
  270. endm
  271. ?ri macro n,r
  272. irp x,<r>
  273. .ERRNDEF ?&&x
  274. n=n or ?&&x
  275. endm
  276. endm
  277. .xcref
  278. .xcref parmB,parmW,parmD,parmQ,parmT,parmCP,parmDP
  279. .cref
  280. parmB macro n
  281. ?pp <n>,<byte>,2,1
  282. endm
  283. parmW macro n
  284. ?pp <n>,<word>,2,2
  285. endm
  286. parmD macro n
  287. ife ?PLM
  288. irp x,<n>
  289. ?pp <&&x>,<dword>,0,4
  290. ?pp <off_&&x>,<word>,2,2
  291. ?pp <seg_&&x>,<word>,2,2
  292. endm
  293. else
  294. irp x,<n>
  295. ?pp <seg_&&x>,<word>,2,2
  296. ?pp <off_&&x>,<word>,2,2
  297. ?pp <&&x>,<dword>,0,4
  298. endm
  299. endif
  300. endm
  301. parmQ macro n
  302. ?pp <n>,<qword>,8,8
  303. endm
  304. parmT macro n
  305. ?pp <n>,<tbyte>,10,10
  306. endm
  307. if sizec
  308. parmCP macro n
  309. parmD <n>
  310. endm
  311. else
  312. parmCP macro n
  313. parmW <n>
  314. endm
  315. endif
  316. if sized
  317. parmDP macro n
  318. parmD <n>
  319. endm
  320. else
  321. parmDP macro n
  322. parmW <n>
  323. endm
  324. endif
  325. ?pp macro n,t,l,s
  326. if ?cpd
  327. .xcref
  328. irp x,<n>
  329. .xcref ?t&&x
  330. ?t&&x=s
  331. ife ?PLM
  332. ?pp1 x,<t>,,,%(?po+?adj)
  333. ?po=?po+l
  334. else
  335. ?PLMPrevParm=?PLMPrevParm+1
  336. ?po=?po+l
  337. ?pp1 x,<t>,%?po,%?adj,,%?PLMPrevParm,%(?PLMPrevParm-1)
  338. endif
  339. endm
  340. .cref
  341. else
  342. ??error <parm(s) "&n" declared outside proc def>
  343. endif
  344. endm
  345. ?pp1 macro n,t,o,a,b,cpc,ppc
  346. ife ?PLM
  347. n equ (t ptr [ebp+b])
  348. else
  349. .xcref
  350. .xcref ?PLMParm&cpc
  351. .cref
  352. ?PLMParm&cpc ¯o po
  353. uconcat <n>,,<equ>,,<(t ptr [ebp+>,%(a+po-o),<])>
  354. ?PLMParm&ppc po
  355. purge ?PLMParm&cpc
  356. &endm
  357. endif
  358. endm
  359. ifndef ?NOPARMR
  360. if ?pmd
  361. parmR macro n,r,r2
  362. ??error <Sorry: ParmR can't be used with PMODE=1>
  363. endm
  364. else
  365. .xcref
  366. .xcref ?pr,parmR
  367. .cref
  368. parmR macro n,r,r2
  369. ?pr n,r,r2,%?rp,%(?ia+2)
  370. endm
  371. ?pr macro n,r,r2,i,o
  372. .xcref
  373. ifnb <r2>
  374. parmR seg_&n,r
  375. parmR off_&n,r2
  376. n equ (dword ptr [ebp-o-2])
  377. .xcref ?t&n
  378. ?t&n=4
  379. else
  380. .xcref ?rp&i
  381. ?rp&i=0
  382. ifdef ?&r
  383. ?rp&i=?&r
  384. endif
  385. if ??? or (?cpd eq 0) or (?rp&i eq 0)
  386. ??error <invalid parmR encountered: &n,&r>
  387. exitm
  388. endif
  389. n equ (word ptr [ebp-o])
  390. ?t&n=2
  391. irp x,<bh,ch,dh,bl,cl,dl,ah,al>
  392. if ?&&x eq ?&r
  393. n equ (byte ptr [ebp-o])
  394. ?t&n=1
  395. exitm
  396. endif
  397. endm
  398. ?ia=?ia+2
  399. ?rp=?rp+1
  400. endif
  401. .cref
  402. endm
  403. endif
  404. endif
  405. .xcref
  406. .xcref localB,localW,localD,localQ,localT,localCP,localDP,localV
  407. .cref
  408. localB macro n
  409. ?aloc <n>,<byte ptr>,1,1,0
  410. endm
  411. localW macro n
  412. ?aloc <n>,<word ptr>,2,2,1
  413. endm
  414. localD macro n
  415. irp x,<n>
  416. ?aloc <seg_&&x>,<word ptr>,2,2,1
  417. ?aloc <off_&&x>,<word ptr>,2,2,1
  418. ?aloc <&&x>,<dword ptr>,0,4,1
  419. endm
  420. endm
  421. localQ macro n
  422. ?aloc <n>,<qword ptr>,8,8,1
  423. endm
  424. localT macro n
  425. ?aloc <n>,<tbyte ptr>,10,10,1
  426. endm
  427. if sizec
  428. localCP macro n
  429. localD <n>
  430. endm
  431. else
  432. localCP macro n
  433. localW <n>
  434. endm
  435. endif
  436. if sized
  437. localDP macro n
  438. localD <n>
  439. endm
  440. else
  441. localDP macro n
  442. localW <n>
  443. endm
  444. endif
  445. localV macro n,a
  446. ?aloc <n>,,%(a),0,1
  447. endm
  448. ?aloc macro n,t,l,s,a
  449. if ?cpd
  450. .xcref
  451. irp x,<n>
  452. ???=???+l
  453. if a
  454. ???=((??? + 1) and 0fffeh)
  455. endif
  456. ?al1 x,<t>,%(???+?ia)
  457. .xcref ?t&&x
  458. ?t&&x=s
  459. endm
  460. .cref
  461. else
  462. ??error <locals "&n" declared outside procedure def>
  463. endif
  464. endm
  465. ?al1 macro n,t,o
  466. n equ (t [ebp-o])
  467. endm
  468. ?gcc macro s,i,cc
  469. s = i
  470. ifnb <cc>
  471. ifidn <cc>,<C>
  472. s=0
  473. endif
  474. ifidn <cc>,<PLM>
  475. s=1
  476. endif
  477. ifidn <cc>,<PASCAL>
  478. s=1
  479. endif
  480. endif
  481. endm
  482. ifndef ?NOGLOBAL
  483. .xcref
  484. .xcref globalB,globalW,globalD,globalQ,globalT,globalCP,globalDP
  485. .cref
  486. globalB macro n,i,s,c
  487. ?ad <n>,1
  488. ?dd n,1,<byte>,<db>,<i>,<s>,<c>
  489. endm
  490. globalW macro n,i,s,c
  491. ?ad <n>,2
  492. ?dd n,1,<word>,<dw>,<i>,<s>,<c>
  493. endm
  494. globalD macro n,i,s,c
  495. ?ad <n>,4
  496. ?dd n,1,<dword>,<dd>,<i>,<s>,<c>
  497. off_&n equ n
  498. seg_&n equ n[2]
  499. endm
  500. globalQ macro n,i,s,c
  501. ?ad <n>,8
  502. ?dd n,1,<qword>,<dq>,<i>,<s>,<c>
  503. endm
  504. globalT macro n,i,s,c
  505. ?ad <n>,10
  506. ?dd n,1,<tbyte>,<dt>,<i>,<s>,<c>
  507. endm
  508. if sizec
  509. globalCP macro n,i,s,c
  510. globalD n,<i>,<s>,<c>
  511. endm
  512. else
  513. globalCP macro n,i,s,c
  514. globalW n,<i>,<s>,<c>
  515. endm
  516. endif
  517. if sized
  518. globalDP macro n,i,s,c
  519. globalD n,<i>,<s>,<c>
  520. endm
  521. else
  522. globalDP macro n,i,s,c
  523. globalW n,<i>,<s>,<c>
  524. endm
  525. endif
  526. endif
  527. ifndef ?NOSTATIC
  528. .xcref
  529. .xcref staticB,staticW,staticD,staticQ,staticT,staticCP,staticDP
  530. .cref
  531. staticB macro n,i,s
  532. ?ad <n>,1
  533. ?dd n,0,<byte>,<db>,<i>,<s>,<PLM>
  534. endm
  535. staticW macro n,i,s
  536. ?ad <n>,2
  537. ?dd n,0,<word>,<dw>,<i>,<s>,<PLM>
  538. endm
  539. staticD macro n,i,s
  540. ?ad <n>,4
  541. ?dd n,0,<dword>,<dd>,<i>,<s>,<PLM>
  542. endm
  543. staticQ macro n,i,s
  544. ?ad <n>,8
  545. ?dd n,0,<qword>,<dq>,<i>,<s>,<PLM>
  546. endm
  547. staticT macro n,i,s
  548. ?ad <n>,10
  549. ?dd n,0,<tbyte>,<dt>,<i>,<s>,<PLM>
  550. endm
  551. if sizec
  552. staticCP macro n,i,s
  553. staticD n,<i>,<s>
  554. endm
  555. else
  556. staticCP macro n,i,s
  557. staticW n,<i>,<s>
  558. endm
  559. endif
  560. if sized
  561. staticDP macro n,i,s
  562. staticD n,<i>,<s>
  563. endm
  564. else
  565. staticDP macro n,i,s
  566. staticW n,<i>,<s>
  567. endm
  568. endif
  569. endif
  570. ?dd macro n,p,t,d,i,s,c
  571. ?gcc ?dd2,%?PLM,<c>
  572. ife ?dd2
  573. n label t
  574. ?dd1 _&n,p,<d>,<i>,<s>
  575. else
  576. ?dd1 n,p,<d>,<i>,<s>
  577. endif
  578. endm
  579. ?dd1 macro n,p,d,i,s
  580. if p
  581. public n
  582. endif
  583. ifb <s>
  584. n d i
  585. else
  586. ifb <i>
  587. n d s dup (?)
  588. else
  589. n d s dup (i)
  590. endif
  591. endif
  592. endm
  593. ifndef ?NOEXTERN
  594. .xcref
  595. .xcref ?ex1,?ex2,externB,externW,externD,externQ,externT
  596. .xcref externNP,externFP,externP,externCP,externDP,externA
  597. .cref
  598. ?ex2 = 0
  599. externA macro n,c
  600. ?ex1 <n>,40h,<abs>,<c>,<>
  601. endm
  602. externB macro n,c
  603. ?ex1 <n>,1,<byte>,<c>,<>
  604. endm
  605. externW macro n,c
  606. ?ex1 <n>,2,<word>,<c>,<>
  607. endm
  608. externD macro n,c
  609. ?ex1 <n>,4,<dword>,<c>,<>
  610. endm
  611. externQ macro n,c
  612. ?ex1 <n>,8,<qword>,<c>,<>
  613. endm
  614. externT macro n,c
  615. ?ex1 <n>,10,<tbyte>,<c>,<>
  616. endm
  617. externNP macro n,c
  618. ?ex1 <n>,2,<near>,<c>,<cc>
  619. endm
  620. externFP macro n,c
  621. ?ex1 <n>,4,<far>,<c>,<cc>
  622. endm
  623. if sizec
  624. externP macro n,c
  625. ?ex1 <n>,4,<far>,<c>,<cc>
  626. endm
  627. else
  628. externP macro n,c
  629. ?ex1 <n>,2,<near>,<c>,<cc>
  630. endm
  631. endif
  632. if sizec
  633. externCP macro n,c
  634. ?ex1 <n>,4,<dword>,<c>,<>
  635. endm
  636. else
  637. externCP macro n,c
  638. ?ex1 <n>,2,<word>,<c>,<>
  639. endm
  640. endif
  641. if sized
  642. externDP macro n,c
  643. ?ex1 <n>,4,<dword>,<c>,<>
  644. endm
  645. else
  646. externDP macro n,c
  647. ?ex1 <n>,2,<word>,<c>,<>
  648. endm
  649. endif
  650. ?ex1 macro n,s,d,c,scv
  651. ?gcc ?ex2,%?PLM,<c>
  652. irp x,<n>
  653. .xcref
  654. .xcref ?t&&x
  655. .cref
  656. ?t&&x=s
  657. ife ?ex2
  658. extrn _&&x:&d
  659. x equ _&&x
  660. else
  661. extrn x:&d
  662. endif
  663. ifidn <scv>,<cc>
  664. .xcref
  665. .xcref ?CC&&x
  666. .cref
  667. ?CC&&x=?ex2
  668. endif
  669. endm
  670. endm
  671. endif
  672. ifndef ?NOLABEL
  673. .xcref
  674. .xcref ?lb1,?lblpu,?lb2
  675. .xcref labelB,labelW,labelD,labelQ,labelT
  676. .xcref labelNP,labelFP,labelP,labelCP,labelDP
  677. .cref
  678. ?lblpu = 0
  679. ?lb2 = 0
  680. labelB macro n,c
  681. ?lb1 <n>,1,<byte>,<c>
  682. endm
  683. labelW macro n,c
  684. ?lb1 <n>,2,<word>,<c>
  685. endm
  686. labelD macro n,c
  687. ?lb1 <n>,4,<dword>,<c>
  688. endm
  689. labelQ macro n,c
  690. ?lb1 <n>,8,<qword>,<c>
  691. endm
  692. labelT macro n,c
  693. ?lb1 <n>,10,<tbyte>,<c>
  694. endm
  695. labelNP macro n,c
  696. ?lb1 <n>,2,<near>,<c>
  697. endm
  698. labelFP macro n,c
  699. ?lb1 <n>,4,<far>,<c>
  700. endm
  701. if sizec
  702. labelP macro n,c
  703. ?lb1 <n>,4,<far>,<c>
  704. endm
  705. else
  706. labelP macro n,c
  707. ?lb1 <n>,2,<near>,<c>
  708. endm
  709. endif
  710. if sizec
  711. labelCP macro n,c
  712. ?lb1 <n>,4,<dword>,<c>
  713. endm
  714. else
  715. labelCP macro n,c
  716. ?lb1 <n>,2,<word>,<c>
  717. endm
  718. endif
  719. if sized
  720. labelDP macro n,c
  721. ?lb1 <n>,4,<dword>,<c>
  722. endm
  723. else
  724. labelDP macro n,c
  725. ?lb1 <n>,2,<word>,<c>
  726. endm
  727. endif
  728. ?lb1 macro n,s,d,c
  729. ?gcc ?lb2,%?PLM,<c>
  730. ?lblpu=0
  731. irp x,<n>
  732. ifidn <x>,<PUBLIC>
  733. ?lblpu=1
  734. else
  735. .xcref
  736. .xcref ?t&&x
  737. .cref
  738. ?t&&x=s
  739. ife ?lb2
  740. if ?lblpu
  741. public _&&x
  742. endif
  743. _&&x label &d
  744. x equ _&&x
  745. else
  746. if ?lblpu
  747. public x
  748. endif
  749. x label &d
  750. endif
  751. endif
  752. endm
  753. endm
  754. endif
  755. ifndef ?NODEF
  756. .xcref
  757. .xcref defB,defW,defD,defQ,defT,defCP,defDP
  758. .cref
  759. defB macro n
  760. ?ad <n>,1
  761. endm
  762. defW macro n
  763. ?ad <n>,2
  764. endm
  765. defD macro n
  766. ?ad <n>,4
  767. endm
  768. defQ macro n
  769. ?ad <n>,8
  770. endm
  771. defT macro n
  772. ?ad <n>,10
  773. endm
  774. if sizec
  775. defCP macro n
  776. defD <n>
  777. endm
  778. else
  779. defCP macro n
  780. defW <n>
  781. endm
  782. endif
  783. if sized
  784. defDP macro n
  785. defD <n>
  786. endm
  787. else
  788. defDP macro n
  789. defW <n>
  790. endm
  791. endif
  792. endif
  793. ?ad macro n,s
  794. irp x,<n>
  795. .xcref
  796. .xcref ?t&&x
  797. .cref
  798. ?t&&x=s
  799. endm
  800. endm
  801. ifndef ?NOPTR
  802. .xcref
  803. .xcref regPtr,farPtr
  804. .cref
  805. regPtr macro n,s,o
  806. farPtr n,s,o
  807. endm
  808. farPtr macro n,s,o
  809. .xcref
  810. .xcref ?t&n
  811. .cref
  812. n ¯o
  813.     push    s
  814.     push    o
  815. &endm
  816. ?t&n=80h
  817. endm
  818. endif
  819. arg macro a
  820. irp x,<a>
  821. ?argc=?argc+1
  822. ?atal <x>,%?argc
  823. endm
  824. endm
  825. ?atal macro n,i
  826. .xcref
  827. .xcref ?ali&i
  828. .cref
  829. ?ali&i ¯o
  830. ?ap n
  831. &endm
  832. endm
  833. ?ap macro n
  834. ?argl=?argl+2
  835. ifdef ?t&n
  836. ife ?t&n-1
  837.     push    word ptr (n)
  838. exitm
  839. endif
  840. ife ?t&n-2
  841.     push    n
  842. exitm
  843. endif
  844. ife ?t&n-4
  845.     push    word ptr (n)[2]
  846.     push    word ptr (n)
  847. ?argl=?argl+2
  848. exitm
  849. endif
  850. ife ?t&n-8
  851.     push    word ptr (n)[6]
  852.     push    word ptr (n)[4]
  853.     push    word ptr (n)[2]
  854.     push    word ptr (n)
  855. ?argl=?argl+6
  856. exitm
  857. endif
  858. if ?t&n and 80h
  859. n
  860. ?argl=?argl+2
  861. exitm
  862. endif
  863. ife ?t&n
  864.     push    word ptr (n)
  865. exitm
  866. endif
  867. endif
  868.     push    n
  869. endm
  870. cCall macro n,a,c
  871. ifnb <a>
  872. arg <a>
  873. endif
  874. mpush %?rsl
  875. ifdef ?CC&n
  876. ?cCall1=?CC&n
  877. else
  878. ?cCall1=?PLM
  879. endif
  880. ifnb <c>
  881. ?gcc ?cCall1,%?cCall1,<c>
  882. endif
  883. ?argl=0
  884. ife ?cCall1
  885. ?acb=?argc
  886. else
  887. ?acb=1
  888. endif
  889. rept ?argc
  890. uconcat <?ali>,%?acb
  891. uconcat <purge>,,<?ali>,%?acb
  892. ife ?cCall1
  893. ?acb=?acb-1
  894. else
  895. ?acb=?acb+1
  896. endif
  897. endm
  898.     call    n
  899. if ((?cCall1 eq 0) and (?argl ne 0))
  900.     add    sp,?argl
  901. endif
  902. mpop %?rsl
  903. ?rsl=0
  904. ?argc= 0
  905. ?argl= 0
  906. endm
  907. cProc macro n,cf,a
  908. if ?cpd
  909. ?utpe
  910. endif
  911. ?cpd=1
  912. ???=0
  913. ?argc=0
  914. ?ba=0
  915. ?po=0
  916. ?pu=0
  917. ?ia=0
  918. ?adj=4
  919. ?rp=0
  920. ?uf=0
  921. ?wfp=?WIN
  922. ?ff=0
  923. ?pas=0
  924. ?pcc=?PLM
  925. ?lds=0
  926. ?exp=0
  927. ifnb <a>
  928. ?ri ?pas,<a>
  929. endif
  930. ?pc=sizec
  931. ?nd=?nodata1
  932. ?nx=0
  933. irp x,<cf>
  934. ifidn <x>,<FAR>
  935. ?pc=1
  936. endif
  937. ifidn <x>,<NEAR>
  938. ?pc=0
  939. endif
  940. ifidn <x>,<PUBLIC>
  941. ?pu=1
  942. endif
  943. ifidn <x>,<SMALL>
  944. ?uf=1
  945. endif
  946. ifidn <x>,<DATA>
  947. ?nd=0
  948. endif
  949. ifidn <x>,<NODATA>
  950. ?nd=1
  951. endif
  952. ifidn <x>,<ATOMIC>
  953. ?nx=1
  954. endif
  955. ifidn <x>,<C>
  956. ?pcc=0
  957. endif
  958. ifidn <x>,<PLM>
  959. ?pcc=1
  960. endif
  961. ifidn <x>,<PASCAL>
  962. ?pcc=1
  963. endif
  964. ifidn <x>,<WIN>
  965. ?wfp=1
  966. endif
  967. ifidn <x>,<NONWIN>
  968. ?wfp=0
  969. endif
  970. ifidn <x>,<LOADDS>
  971. ?lds=1
  972. endif
  973. ifidn <x>,<EXPORTED>
  974. ?exp=1
  975. endif
  976. endm
  977. if ?pcc
  978. ?PLMPrevParm=0
  979. .xcref
  980. .xcref ?PLMParm0
  981. .cref
  982. ?PLMParm0 ¯o
  983. purge ?PLMParm0
  984. &endm
  985. endif
  986. .xcref
  987. .xcref ?CC&n
  988. .cref
  989. ?CC&n=?pcc
  990. if (?nx eq 1) and (?nd eq 0)
  991. ?nx = 0
  992. ??error <ATOMIC specified without NODATA - ATOMIC ignored>
  993. endif
  994. if ?pc
  995. if ?wfp+?exp+?lds
  996. ife ?nx
  997. ife ?pmd
  998. ?ia=2
  999. endif
  1000. ?pas = ?pas and (not ?ds)
  1001. endif
  1002. endif
  1003. ?adj=?adj+2
  1004. else
  1005. ?wfp=0
  1006. endif
  1007. ife ?386regs
  1008. ?pas = ?pas and (not (?sp+?cs+?ss))
  1009. endif
  1010. if ?uf
  1011. if ?386regs
  1012. ?pas = ?pas and (not (?si+?di))
  1013. else
  1014. ?pas = ?pas and (not (?bp+?si+?di))
  1015. endif
  1016. endif
  1017. ife ?pcc
  1018. ?pg <_&n>,%?pu,%?pc,%?pas,%?wfp,<n>,%?pcc
  1019. else
  1020. ?pg <n>,%?pu,%?pc,%?pas,%?wfp,<n>,%?pcc
  1021. endif
  1022. endm
  1023. ?pg macro n,p,c,a,w,nnu,cc
  1024. .xcref
  1025. if ?uf
  1026. if ?nd
  1027. ??error <NODATA encountered in &n - user frame ignored>
  1028. ?uf=0
  1029. endif
  1030. endif
  1031. .xcref cBegin
  1032. cBegin ¯o g
  1033. .xcref
  1034. if cc
  1035. uconcat <?PLMParm>,%?PLMPrevParm,%?po
  1036. endif
  1037. if ?uf
  1038. if ?rp
  1039. ??error <parmR encountered in &n - user frame ignored>
  1040. ?uf=0
  1041. endif
  1042. endif
  1043. ?pg1 <n>,c,a,%?po,w,%?uf,%?nd,%?rp,cc
  1044. ?cpd=0
  1045. ?argc=0
  1046. ?ba=1
  1047. ???=(???+1) and 0fffeh
  1048. if p
  1049. public n
  1050. endif
  1051.  
  1052. ife c
  1053. n proc near
  1054. else
  1055. if ?auto32
  1056. &n&_fix_cs:
  1057.     db 057h                     ; push    di
  1058.     db 083h,0ECh,008h           ; sub     sp,8
  1059.     db 08Ch,0CBh                ; mov     bx,cs
  1060.     db 08Ch,0D0h                ; mov     ax,ss
  1061.     db 08Eh,0C0h                ; mov     es,ax
  1062.     db 08Bh,0FCh                ; mov     di,sp
  1063.     db 0B8h,00Bh,000h           ; mov     ax,000Bh
  1064.     db 0CDh,031h                ; int     31h
  1065.     db 026h,080h,04Dh,006h,040h ; or      byte ptr es:[di+6],40h
  1066.     db 0B8h,00Ch,000h           ; mov     ax,000Ch
  1067.     db 0CDh,031h                ; int     31h
  1068.     add     sp,8                ; db 083h,0C4h,008h
  1069.     pop     di                  ; db 05Fh
  1070. align 4
  1071. n proc far
  1072.     xor eax,eax
  1073.     mov ah,80h
  1074.     add eax,eax
  1075.     jc  short &n&_fix_cs
  1076. else
  1077. n proc far
  1078. endif
  1079. endif
  1080.  
  1081. ife cc
  1082. nnu equ n
  1083. endif
  1084. ifidn <g>,<nogen>
  1085. if ???+?po+a+?rp
  1086. ??_out <cBegin - possible invalid use of nogen>
  1087. endif
  1088. else
  1089. if ?uf
  1090. ?mf c,%???,%?po
  1091. mpush a
  1092. else
  1093. if w+?exp+?lds
  1094. if ?pmd
  1095. ife ?nd
  1096. if ?lds
  1097. mov ax,_DATA
  1098. else
  1099. if ?exp
  1100. mov ax,ds
  1101. nop
  1102. endif
  1103. endif
  1104. endif
  1105. ife ?nx
  1106. if ???+?po
  1107. if ?chkstk1
  1108.     push bp
  1109.     movzx ebp,sp
  1110. else
  1111. if ???
  1112.     push    bp
  1113.     movzx   ebp, sp
  1114.     sub     sp, ???
  1115.  
  1116. ;;;;;enter ???,0
  1117. ;;;;;movzx bp,bp
  1118.  
  1119. else
  1120. push bp
  1121. movzx ebp,sp
  1122. endif
  1123. endif
  1124. endif
  1125. push ds
  1126. if ?lds+?exp
  1127. mov ds,ax
  1128. endif
  1129. else
  1130. if ?ff+???+?po+?rp
  1131.         push    bp
  1132.         movzx   ebp,sp
  1133. endif
  1134. endif
  1135. else
  1136. ife ?nd
  1137.     mov    ax,ds
  1138.     nop
  1139. endif
  1140. ife ?nx
  1141. ife ?DOS5
  1142.         inc     bp
  1143. endif
  1144.         push    bp
  1145.         movzx   ebp,sp
  1146.     push    ds
  1147. else
  1148. if ?ff+???+?po+?rp
  1149.         push    bp
  1150.         movzx   ebp,sp
  1151. endif
  1152. endif
  1153. ife ?nd
  1154.     mov    ds,ax
  1155. endif
  1156. endif
  1157. else
  1158. if ?pmd
  1159. if ?exp
  1160. mov ax,ds
  1161. nop
  1162. else
  1163. if ?lds
  1164. mov ax,_DATA
  1165. endif
  1166. endif
  1167. if ?ff+???+?po+?rp
  1168. if ?chkstk1
  1169. push bp
  1170. movzx ebp,sp
  1171. else
  1172. if ???
  1173.  
  1174.     push    bp
  1175.     movzx   ebp, sp
  1176.     sub     sp, ???
  1177.  
  1178. ;;;;enter ???,0
  1179. ;;;;movzx ebp,bp
  1180. else
  1181. push  bp
  1182. movzx ebp,sp
  1183. endif
  1184. endif
  1185. endif
  1186. if ?exp+?lds
  1187. push ds
  1188. mov ds,ax
  1189. endif
  1190. else
  1191. if ?ff+???+?po+?rp
  1192.         push    bp
  1193.         movzx   ebp,sp
  1194. endif
  1195. endif
  1196. endif
  1197. if ?rp
  1198. ?uf=0
  1199. rept ?rp
  1200. uconcat mpush,,?rp,%?uf
  1201. ?uf=?uf+1
  1202. endm
  1203. endif
  1204. if ???
  1205. if ?chkstk1
  1206. ifdef ?CHKSTKPROC
  1207. ?CHKSTKPROC %???
  1208. else
  1209.     mov    ax,???
  1210. ife cc
  1211.     call    _chkstk
  1212. else
  1213.     call    chkstk
  1214. endif
  1215. endif
  1216. else
  1217. ife ?pmd
  1218.     sub    sp,???
  1219. endif
  1220. endif
  1221. endif
  1222. mpush a
  1223. endif
  1224. ifdef ?PROFILE
  1225. if c
  1226.     call    StartNMeas
  1227. endif
  1228. endif
  1229. endif
  1230. .cref
  1231. purge cBegin
  1232. &endm
  1233. .xcref ?utpe
  1234. ?utpe ¯o
  1235. ??error <unterminated procedure definition: "&n">
  1236. &endm
  1237. .cref
  1238. endm
  1239. ?pg1 macro n,c,a,o,w,f,d,r,cc
  1240. .xcref
  1241. .xcref cEnd
  1242. cEnd ¯o g
  1243. .xcref
  1244. ?ba=0
  1245. ifidn <g>,<nogen>
  1246. if o+a+r
  1247. ??_out <cEnd - possible invalid use of nogen>
  1248. endif
  1249. else
  1250. ifdef ?PROFILE
  1251. if c
  1252. call StopNMeas
  1253. endif
  1254. endif
  1255. mpop a
  1256. if f
  1257.     db    0c3h
  1258. else
  1259. if w+?exp+?lds
  1260. if ?pmd
  1261. ife ?nx
  1262. pop ds
  1263. endif
  1264. ife ?nx
  1265. if ?chkstk1+???+?po
  1266. ;;;;lea     sp,-4[bp]
  1267. if ???
  1268.     add     sp, ???
  1269. endif
  1270.     pop     bp
  1271. ;;;;leave
  1272. endif
  1273. else
  1274. if ?ff+???+?po+?rp
  1275.  
  1276. ;;;;lea     sp,-4[bp]
  1277. if ???
  1278.     add     sp, ???
  1279. endif
  1280.     pop     bp
  1281.     
  1282.  
  1283. ;;;;;;;;;;;;;;;;;;;leave
  1284. endif
  1285. endif
  1286. else
  1287. ife ?nx
  1288. if (?TF eq 0) or (???+?rp)
  1289.         lea     sp,-2[bp]
  1290. endif
  1291.     pop    ds
  1292.         pop     bp
  1293. ife ?DOS5
  1294.         dec     bp
  1295. endif
  1296. else
  1297. if (?TF eq 0) or (???+?rp)
  1298.         mov     sp,bp
  1299. endif
  1300. if ???+?po+?rp
  1301.         pop     bp
  1302. endif
  1303. endif
  1304. endif
  1305. else
  1306. if ?pmd
  1307. if ?ff+???+?po+?rp
  1308. ;;;;lea     sp,-4[bp]
  1309. if  ???
  1310.     add     sp, ???
  1311. endif
  1312.     pop     bp
  1313. ;;;;;;;;;;;;;;;;;;;;;;;;leave
  1314. endif
  1315. else
  1316. if ?ff+???+?po+?rp
  1317. if (?TF eq 0) or (???+?rp)
  1318.         mov     sp,bp
  1319. endif
  1320.         pop     bp
  1321. endif
  1322. endif
  1323. endif
  1324. ife cc
  1325.         db      66h
  1326.         retf
  1327. else
  1328.         db      66h
  1329.         retf    o
  1330. endif
  1331. endif
  1332. endif
  1333. n endp
  1334. .cref
  1335. purge cEnd
  1336. &endm
  1337. .cref
  1338. endm
  1339. assumes macro s,ln
  1340. ifndef ln&_assumes
  1341. assume s:ln
  1342. else
  1343. ln&_assumes s
  1344. endif
  1345. endm
  1346. createSeg macro n,ln,a,co,cl,grp
  1347. ifnb <grp>
  1348. addseg grp,n
  1349. else
  1350. ln&OFFSET equ offset n:
  1351. ln&BASE equ n
  1352. ?cs3 <ln>,<n>
  1353. endif
  1354. ifnb <cl>
  1355. n segment a co '&cl'
  1356. else
  1357. n segment a co
  1358. endif
  1359. n ends
  1360. ?cs1 <ln>,<n>
  1361. endm
  1362. addseg macro grp,seg
  1363. .xcref
  1364. .xcref grp&_def
  1365. .cref
  1366. ifndef grp&_def
  1367. grp&_def=0
  1368. endif
  1369. if grp&_def ne ASMpass
  1370. .xcref
  1371. .xcref grp&_add
  1372. .cref
  1373. grp&_add ¯o s
  1374. grp&_in <seg>,s
  1375. &endm
  1376. .xcref
  1377. .xcref grp&_in
  1378. .cref
  1379. grp&_in ¯o sl,s
  1380. ifb <s>
  1381. grp group sl
  1382. else
  1383. grp&_add ¯o ns
  1384. grp&_in <sl,s>,ns
  1385. &endm
  1386. endif
  1387. &endm
  1388. grp&_def=ASMpass
  1389. else
  1390. grp&_add seg
  1391. endif
  1392. endm
  1393. defgrp macro grp,ln
  1394. addseg grp
  1395. ifnb <ln>
  1396. irp x,<ln>
  1397. ?cs3 <&x>,<grp>
  1398. x&&OFFSET equ offset grp:
  1399. x&&BASE equ grp
  1400. endm
  1401. endif
  1402. endm
  1403. ?cs1 macro ln,n
  1404. .xcref
  1405. .xcref ln&_sbegin
  1406. .cref
  1407. ln&_sbegin ¯o
  1408. .xcref
  1409. .xcref ?mf
  1410. .cref
  1411. ?mf &¯o c,l,p
  1412. if c
  1413.     extrn    n&_FARFRAME:near
  1414.     call    n&_FARFRAME
  1415. else
  1416.     extrn    n&_NEARFRAME:near
  1417.     call    n&_NEARFRAME
  1418. endif
  1419.     db    l shr 1
  1420.     db    p shr 1
  1421. &&endm
  1422. ?cs2 <ln>,<n>
  1423. n segment
  1424. &endm
  1425. endm
  1426. ?cs2 macro ln,n
  1427. .xcref
  1428. .xcref sEnd
  1429. .cref
  1430. sEnd ¯o
  1431. n ends
  1432. purge ?mf
  1433. purge sEnd
  1434. &endm
  1435. endm
  1436. ?cs3 macro ln,n
  1437. .xcref
  1438. .xcref ln&_assumes
  1439. .cref
  1440. ln&_assumes ¯o s
  1441. assume s:&n
  1442. &endm
  1443. endm
  1444. .xcref
  1445. .xcref sBegin
  1446. .cref
  1447. sBegin macro ln
  1448. ln&_sbegin
  1449. endm
  1450. ife ?DF
  1451. ;.286p
  1452. ;createSeg _TEXT,Code,word,public,CODE
  1453. ;.386p
  1454. ;createSeg _TEXT32,Code32,word,use32,CODE
  1455. ife ?nodata1
  1456. .286p
  1457. createSeg _DATA,Data,word,public,DATA,DGROUP
  1458. .386p
  1459. defgrp DGROUP,Data
  1460. endif
  1461. if ?chkstk1
  1462. ifndef ?CHKSTKPROC
  1463. externp <chkstk>
  1464. endif
  1465. endif
  1466. endif
  1467. errnz macro x
  1468. if2
  1469. if x
  1470. errnz1 <x>,%(x)
  1471. endif
  1472. endif
  1473. endm
  1474. errnz1 macro x1,x2
  1475. = *errnz* x1 = x2
  1476. .err
  1477. endm
  1478. errn$ macro l,x
  1479. errnz <offset $ - offset l x>
  1480. endm
  1481. ifdef ?PROFILE
  1482. externFP <StartNMeas,StopNMeas>
  1483. endif
  1484.